
package com.ebupt.migu.music.global.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ebupt.migu.globalpopup.entity.ApprovedMemo;
import com.ebupt.migu.globalpopup.entity.H5Info;
import com.ebupt.migu.music.common.entity.ResultObject;
import com.ebupt.migu.music.global.mapper.ApprovedMemoMapper;
import com.ebupt.migu.music.global.service.IApprovedMemoService;

/**
 * 审核记录表 服务实现类
 *
 * @author wangzhu
 * @since 2021-11-26
 */
@Service
public class ApprovedMemoServiceImpl extends ServiceImpl<ApprovedMemoMapper, ApprovedMemo>
    implements IApprovedMemoService {

    @Autowired
    private H5InfoServiceImpl h5InfoServiceImpl;

    @Override
    public ResultObject saveApprovedMemo(ApprovedMemo approvedMemo) {
        ResultObject resultObject = new ResultObject();
        this.baseMapper.insert(approvedMemo);
        h5InfoServiceImpl.update(new UpdateWrapper<H5Info>().lambda().eq(true, H5Info::getId, approvedMemo.getH5Id())
            .set(true, H5Info::getStatus, approvedMemo.getStatus()));
        resultObject.setCode("0000");
        resultObject.setMsg("成功");

        return resultObject;
    }
}
